﻿<%@ WebHandler Language="C#" Class="SizeMate_Update" %>

using System;
using System.Web;
using System.Text;
using Newtonsoft.Json;
public class SizeMate_Update : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
    
    public void ProcessRequest (HttpContext context) {
 //检验是否登录
        OTS.Common.PageSuccess page = new OTS.Common.PageSuccess();
        if (!OTS.BaseLogin.validataModule(context, (int)OTS.enumSysRight.SizeManager))
        {
            page.success = false;
            page.msg = "非法操作！";

        }
        else
        {
            string _matName = context.Request["mat.Name"];
            string _matUnit = context.Request["mat.Unit"];
            string _strMatId = context.Request["mat.Id"];
            int _matId;
            int.TryParse(_strMatId, out  _matId);
            if (_matId>0 && null != _matName && !"".Equals(_matName) && null != _matUnit && !"".Equals(_matUnit))
            {
                OTS.Model.size_material model = new OTS.Model.size_material();
                model.sizeMatName = _matName;
                model.sizeUnit = _matUnit;
                model.sizeMatID = _matId;

                OTS.BLL.ProductSizeBLL bll = new OTS.BLL.ProductSizeBLL();
 
                if ( bll.UpdateSizeMate(model))
                {
                    page.success = true;
                    page.msg =  "修改成功！";
                }
                else
                {
                    page.success = false;
                    page.msg = "添加失败！";
                }
                 
                
            }
            else
            {
                page.success = false;
                page.msg = "参数有误！";

            }
        }

        context.Response.ContentType = "application/x-json";
        context.Response.Charset = "utf-8";
        context.Response.Write(JavaScriptConvert.SerializeObject(page));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}